home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dfpp01.zip / BORDER.CPP < prev    next >
C/C++ Source or Header  |  1992-11-21  |  3KB  |  122 lines

  1. // -------- border.cpp
  2.  
  3. #include "desktop.h"
  4. #include "dfwindow.h"
  5.  
  6. void DFWindow::AdjustBorders()
  7. {
  8.     BorderAdj = TopBorderAdj = BottomBorderAdj = 0;
  9.     if (attrib & BORDER)
  10.         BorderAdj = TopBorderAdj = BottomBorderAdj = 1;
  11.     if (attrib & TITLEBAR)
  12.         TopBorderAdj = 1;
  13. }
  14.  
  15. void DFWindow::Title()
  16. {
  17.     if (visible && (attrib & TITLEBAR) && title != NULL)    {
  18.         int wd = ClientWidth();
  19.         int tlen = min(title->Strlen(), wd-4);
  20.         String sp1((wd-tlen)/2, ' ');
  21.         String sp2(wd - (sp1.Strlen() + tlen), ' ');
  22.         String tlin = sp1 + title->left(tlen) + sp2;
  23.         int fg = this == desktop.InFocus() ? WHITE : BLACK;
  24.  
  25.         WriteWindowString(tlin, BorderAdj, 0, fg, CYAN);
  26.         if (attrib & CONTROLBOX)
  27.             WriteWindowChar(CONTROLBOXCHAR, 2, 0, fg, CYAN);
  28.         if (attrib & (MINBOX | MAXBOX))     {
  29.             int tend = ClientWidth() - 1;
  30.             if (windowstate == ISRESTORED)    {
  31.                 if (attrib & MINBOX)
  32.                     WriteWindowChar(MINPOINTER, tend, 0, fg, CYAN);
  33.                 if (attrib & MAXBOX)
  34.                     WriteWindowChar(MAXPOINTER, tend+1, 0, fg, CYAN);
  35.             }
  36.             else if (windowstate == ISMAXIMIZED)    {
  37.                 WriteWindowChar(RESTOREPOINTER, tend+1, 0, fg, CYAN);
  38.                 if (attrib & MINBOX)
  39.                     WriteWindowChar(MINPOINTER, tend, 0, fg, CYAN);
  40.             }
  41.             else if (windowstate == ISMINIMIZED)
  42.                 WriteWindowChar(RESTOREPOINTER, tend+1, 0, fg, CYAN);
  43.         }
  44.     }
  45. }
  46.  
  47. void DFWindow::Border()
  48. {
  49.     if (visible)    {
  50.         if (attrib & BORDER)    {
  51.             unsigned int lin, side, ne, nw, se, sw;
  52.             if (DblBorder && this == desktop.InFocus())    {
  53.                 lin  = FOCUS_LINE;
  54.                 side = FOCUS_SIDE;
  55.                 ne   = FOCUS_NE;
  56.                 nw   = FOCUS_NW;
  57.                 se   = FOCUS_SE;
  58.                 sw   = FOCUS_SW;
  59.             }
  60.             else    {
  61.                 lin  = LINE;
  62.                 side = SIDE;
  63.                 ne   = NE;
  64.                 nw   = NW;
  65.                 se   = SE;
  66.                 sw   = SW;
  67.             }
  68.             int wd = ClientWidth();
  69.             int ht = Height() - 1;
  70.             int rt = Width() - 1;
  71.  
  72.             String line(wd, lin);
  73.  
  74.             // ------- top border
  75.             int fg = colors.ffg;
  76.             int bg = colors.fbg;
  77.             WriteWindowChar(nw, 0,  0, fg, bg);
  78.             WriteWindowChar(ne, rt, 0, fg, bg);
  79.             if (!(attrib & TITLEBAR))
  80.                 WriteWindowString(line, 1, 0, fg, bg);
  81.  
  82.             // ------ side borders
  83.             for (int y = 1; y < ht; y++)    {
  84.                 WriteWindowChar(side, 0, y, fg, bg);
  85.                 if (windowstate != ISRESTORED || !(attrib & VSCROLLBAR))
  86.                     WriteWindowChar(side, rt, y, fg, bg);
  87.             }
  88.  
  89.             // ----- bottom border
  90.             WriteWindowChar(sw, 0,  y, fg, bg);
  91.             WriteWindowChar(se, rt, y, fg, bg);
  92.             if (windowstate != ISRESTORED ||
  93.                     !(attrib & (HSCROLLBAR | STATUSBAR)))
  94.                 WriteWindowString(line, 1, y, fg, bg);
  95.         }
  96.         Title();
  97.     }
  98. }
  99.  
  100. void DFWindow::Shadow()
  101. {
  102.     if (windowstate == ISRESTORED && visible && (attrib & SHADOW))    {
  103.         int lf = Left();
  104.         int tp = Top();
  105.         int ht = Height();
  106.         int wd = Width();
  107.         int x = wd;
  108.         int c;
  109.         for (int y = 1; y < ht; y++)    {
  110.             c = desktop.screen().GetVideoChar(x+lf, y+tp);
  111.             WriteWindowChar(c, x, y, ShadowFG, ShadowBG);
  112.         }
  113.         String ln(wd, ' ');
  114.         for (x = 0; x < wd; x++)
  115.             ln[x] = desktop.screen().GetVideoChar(x+1+lf, y+tp);
  116.         WriteWindowString(ln, 1, y, ShadowFG, ShadowBG);
  117.     }
  118. }
  119.  
  120.  
  121.  
  122.